package com.comit.appointment.producer;


import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class Send {

    public static void main(String[] args) throws IOException {

        RabbitTemplate.ConfirmCallback confirmCallback= (correlationData, isAck, s) -> System.out.println(isAck);

//创建spring容器
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-rabbitmq-producer.xml");
//从容器中获取对象
        RabbitTemplate template = context.getBean(RabbitTemplate.class);
        template.setConfirmCallback(confirmCallback);
// 发送消息
        Map<String, String> map = new HashMap<>();
        map.put("email", "regect@qq.com");
        template.convertAndSend("changeanexchange", "ldw", map);
        //System.in.read();
        context.close();
        System.out.println(2222222);
    }
}